<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>管理后台</title>
    <link rel="stylesheet/less" href="../../../static/css/index.less"/>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../../static/css/jquery.pagination.css"/>
    <script src="../../../static/js/jquery-1.12.3.js"></script>
    <script src="../../../static/js/less.min.js"></script>
    <script src="../../../static/layui/layui.js"></script>
    <script src="../../../static/js/ajaxfileupload.js"></script>
    <script src="../../../static/layer/layer.js"></script>
    <SCRIPT language=javascript src="../../static/layer/layer.js"></SCRIPT>
</head>
<style>
    #test1{
        display: inline-block;
        width:15%;
    }
    .search input{
        display: inline-block;
    }
</style>
<body class="layui-layout-body">

{% include "/admin/top.html" %}
{% include "/admin/left.html" %}

    <div id="box" class="fl">
        <div class="content" style="height: 100%">
            <h3 style="color:  #3D89CB">数据汇总</h3>
            <div class="search">
                <select id="sid">
                    <option value="">选择门店</option>
                    {% if md %}
                    {% for d in md %}
                    <option value="{{ d.storeId }}">{{ d.storeName }}</option>
                    {% endfor %}
                    {% endif %}
                </select>
                <select id="mid">
                    <option value="">选择机器</option>
                    {% if jq %}
                    {% for d in jq %}
                    <option value="{{ d.machineId }}">{{ d.machineNum }}</option>
                    {% endfor %}
                    {% endif %}
                </select>
                <label>开始日期：</label>
                 <input type="text" class="layui-input" id="test1" value="{{ first_day }}"  placeholder="选择日期" style="width: 150px">
                <label>结束日期：</label>
                 <input type="text" class="layui-input" id="test2" value="{{ now_day }}"  placeholder="选择日期" style="width: 150px">
                    <button onclick="get_data(1)" class="s_button" style="background-color:  #3D89CB">搜索</button>
            </div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <thead>
                <tr>
                    <th>日期</th>
                    <th>门店</th>
                    <th>机器编码</th>
                    <th>金额</th>
                </tr>
                </thead>

                <tbody id="content">

                </tbody>
            </table>
                <div id="page" class="ui-pagination-container">

                </div>


    </div>
</div>
</div>

</body>
</html>

<script>

 layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#test1', //指定元素
        });
     laydate.render({
            elem: '#test2', //指定元素
        });
    });
get_data(1);
    function get_data(p){
        var stime = $('#test1').val();
        var etime = $('#test2').val();
        var sid = $('#sid').val();
        var mid = $('#mid').val();
        $.ajax({
            url:"/admin/data_total_post",
            type:"post",
            data:{
                'stime':stime,
                'etime':etime,
                'sid':sid,
                'mid':mid,
                'p':p
            },
            dataType:"json",
            success:function(msg){
                var q = '';
                if (msg.status == 1){
                    for (var i = 0; i < msg.res.length; i++){
                        q += '<tr>';
                        q += '<td>' + msg.day_str + '</td>';
                        q += '<td>' + msg.res[i].storeName + '</td>';
                        q += '<td>' + msg.res[i].machineNum + '</td>';
                        q += '<td>' + msg.res[i].money + '</td>';
                        q += '</tr>';
                    }
                }else {
                    q  += '<tr><td colspan=4 align="center">无数据</td></tr>';
                }
                $('#content').html(q);
                $('#page').html(msg.page);
            }
        })
    }
</script>


